<?php

class Admin_Model_DbTable_Course extends Zend_Db_Table_Abstract
{

    protected $_name = 'courses';

    public function getAllCourse(){
    	return $this->fetchAll();
    }
    
    public function getCourseByID($courseID){
    	return $this->fetchRow("courses_id = $courseID");
    }
    
    public function addCourse($cName,$cLessionCount,$cDesc){
    	$courseData = array(
    			"courses_name"=>$cName,
    			"courses_lession_count"=>$cLessionCount,
    			"courses_description"=>$cDesc,
    			"status"=>0
    			);
    	return $this->insert($courseData);
    }
    
    public function updateCourse($cID,$cName,$cLessionCount,$cDesc){
    	$courseData = array(
    			"courses_name"=>$cName,
    			"courses_lession_count"=>$cLessionCount,
    			"courses_description"=>$cDesc,
    			"status"=>0
    			);
    	return $this->update($courseData, "courses_id = $cID");
    }
    
    public function changeStt($cID){
    	$course = $this->fetchRow("courses_id = $cID");
    	if($course["status"] == 0){
    		return $this->update(array("status"=>1), "courses_id = $cID");
    	}else{
    		return $this->update(array("status"=>0), "courses_id = $cID");
    	}
    }
}

